package com.situ.water_Invoice.controller;


import com.situ.util.ResponseData;
import com.situ.water_Invoice.mapper.IvIninvoiceMapper;
import com.situ.water_Invoice.mapper.IvInvoiceMapper;
import com.situ.water_Invoice.pojo.FPZB;
import com.situ.water_Invoice.pojo.IvIninvoice;
import com.situ.water_Invoice.pojo.IvInvoice;
import com.situ.water_Invoice.service.IvIninvoiceService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Angel
 * @since 2020-12-01
 */
@RestController
public class IvIninvoiceController {

    @Autowired
    IvIninvoiceService service;
    @Autowired
    IvIninvoiceMapper mapper;
    @Autowired
    IvInvoiceMapper mapper1;

    //比较发票号码是否存在
    @PostMapping("/iv-in-StartNo")
    public int bj( String StartNo){
        IvIninvoice stra = service.queryId(StartNo);
        int str = 0;
        if(stra == null){
            str=1;
        }else{
            str=0;
        }
        return str;//ResponseData.ok().putDataValue("list", list);
    }

    //入库
    @PostMapping("/iv-add")
    public int  addIvIninvoice(IvIninvoice ivIninvoice){
        int add = service.add(ivIninvoice);
        if(add!=0){
            System.out.println("入库成功！");
        }else{
            System.out.println("入库失败!");
        }
        return add;
    }

    //把id添加到 Iv_Invoice表中
    @PostMapping("/getInId")
    public int add(){
        IvIninvoice ivinid = mapper.Ivinid();
        System.out.println(ivinid.getId());
        IvInvoice list = mapper1.querynull();
        mapper1.updateInInvoice(ivinid.getId(), list.getInvoiceNo());
        int o=0;
        return o;
    }


}

